package com.qf.air.controller;

import com.qf.air.service.SearchService;
import com.qf.air.vo.ResultVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.io.IOException;
import java.util.Map;

/**
 * 搜索模块对外提供的功能接口
 */
@RestController
@RequestMapping("/search")
public class SearchController {

    @Autowired
    private SearchService searchService;

    /**
     * 查询ES中存储的空气质量信息
     * @param map
     *      分页信息,查询条件
     * @return
     */
    @PostMapping("/list")
    public ResultVO list(@RequestBody Map map) throws IOException {
        ResultVO vo = searchService.findByPageAndDistrictId(map);
        return vo;
    }

    /**
     * 添加空气质量信息到ES
     * @param map
     */
    @PostMapping("/add")
    public void add(@RequestBody Map map) throws IOException {
        searchService.add(map);
    }

    @PostMapping("/echarts")
    public ResultVO findDistrictAirQualityCount() throws IOException {
        return searchService.findDistrictAirQualityCount();
    }















}
